Skip to content

Add contributors image generation action#4

Open
skyash-dev wants to merge 3 commits into
processing:mainfrom
skyash-dev:main
Open

Add contributors image generation action#4
skyash-dev wants to merge 3 commits into
processing:mainfrom
skyash-dev:main

Conversation

@skyash-dev
Copy link
Copy Markdown

@skyash-dev skyash-dev commented Apr 11, 2026

#1
This introduces a reusable github action that generates a contributors image from the .all-contributorsrc file.

what it does:

  • reads contributors from .all-contributorsrc
  • fetches avatar images
  • renders a grid image (contributors.png)
  • commits the image to a dedicated branch
  • opens a pull request automatically

implementation details:

  • uses github api (octokit)
  • handles branch creation and force updates to keep it in sync with base
  • avoids duplicate PRs by checking existing ones
  • separates image generation logic

tests:

GITHUB_TOKEN must be configured with the appropriate workflow permissions:

  • enable read and write permissions
  • enable allow github actions to create and approve pull requests

@skyash-dev
Copy link
Copy Markdown
Author

@ksen0

Comment thread action.yml Outdated
@NalinDalal
Copy link
Copy Markdown

@skyash-dev i appreciate you doing this, not a maintainer but a fellow contributor.
Saw your message on discord, you have done an excellent work, but I feel that the code-logic can be optimised more.

Here are following points which i noticed on your code:

  1. The action whenever runs unnecessarily uses github API, even if no changes are present; High chances of rate-limiting.
  2. Image generation also can be optimised
  • Re-downloads every avatar via fetch
  • Re-renders the full canvas
  • Re-encodes PNG
    This can be memoized I guess.
  1. Force-Reset

You force-reset update-contributors-png to main every run:
updateRef(..., force: true)
This guarantees a new commit path even if nothing changed.

  1. Compare previous and new image config
    There is no comparison between:
  • existing contributors.png
  • newly generated image
    So even identical output may still trigger a commit attempt.
  1. PR logic
    You only avoid duplicate PRs, but you do not avoid redundant updates inside the branch.

What this means in practice:

  • Unnecessary GitHub API usage
  • Repeated avatar downloads (slow + rate limits risk)
  • Wasted CI time
  • Potential no-op commits if image content is identical

Copy link
Copy Markdown

@NalinDalal NalinDalal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Work can be more optimised for redundancy and other things.

Comment thread generateImage.js
Comment thread index.js
Comment thread index.js
Comment thread index.js
Comment thread index.js
Comment thread generateImage.js
const buffer = Buffer.from(await res.arrayBuffer());
return await loadImage(buffer);
} catch (err) {
return null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent failure (return null) may result in missing avatars without visibility. Consider logging failures (at least debug level) to help diagnose broken avatar URLs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have tested the workflow multiple times and all images are successfully fetched consistently. and if in some case any fails, keeping that blank is a good default i think?

Comment thread README.md
@skyash-dev
Copy link
Copy Markdown
Author

@NalinDalal thank you for the review. funny how almost all fixes trace back to the same underlying issue (missing a comparison between contentBuffer and the existingBuffer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants